package com.wujilee.wujileejuc.cas;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author liwuji
 * @date 2024/7/8
 * @desc
 **/
public class AtomicStampedReferenceTest implements Runnable{
    private Lock lock = new ReentrantLock();

    private static int count = 0;

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(new AtomicStampedReferenceTest());
            thread.start();
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("result: " + count);
    }

    @Override
    public void run() {
        synchronized (AtomicStampedReferenceTest.class) {
            for (int i = 0; i < 1000000; i++)
                count++;
        }
    }

}
